package service

import (
	"context"
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/repository"
	"ruoyi-go-echo-ddd/internal/infrastructure/http/request"
)

type SysMenuService struct {
	Repo repository.SysMenuRepository
}

func NewSysMenuService(repo repository.SysMenuRepository) *SysMenuService {
	return &SysMenuService{
		Repo: repo,
	}
}

func (s *SysMenuService) Insert(ctx context.Context, dept *model.SysMenu) (*model.SysMenu, error) {
	return s.Repo.Insert(ctx, dept)
}

func (s *SysMenuService) Update(ctx context.Context, dept *model.SysMenu) (int64, error) {
	return s.Repo.Update(ctx, dept)
}

func (s *SysMenuService) BatchInsert(ctx context.Context, list []*model.SysMenu) ([]int64, error) {
	return s.Repo.BatchInsert(ctx, list)
}

func (s *SysMenuService) SelectById(ctx context.Context, id int64) (*model.SysMenu, error) {
	return s.Repo.SelectById(ctx, id)
}

func (s *SysMenuService) SelectList(ctx context.Context, param *request.MenuPageParam) ([]*model.SysMenu, error) {
	return s.Repo.SelectList(ctx, param)
}

func (s *SysMenuService) SelectPage(ctx context.Context, param *request.MenuPageParam) ([]*model.SysMenu, int64, int64, error) {
	return s.Repo.SelectPage(ctx, param)
}

func (s *SysMenuService) BatchDelete(ctx context.Context, ids []any) (int64, error) {
	return s.Repo.BatchDelete(ctx, ids)
}

func (s *SysMenuService) SelectListByUserId(ctx context.Context, userId int64, menuName, visible, beginTime, endTime string) ([]*model.SysMenu, error) {
	return s.Repo.SelectListByUserId(ctx, userId, menuName, visible, beginTime, endTime)
}

func (s *SysMenuService) SelectMenuPermsByUserId(ctx context.Context, userId int64) ([]string, error) {
	return s.Repo.SelectMenuPermsByUserId(ctx, userId)
}

func (s *SysMenuService) SelectTreeAll(ctx context.Context) ([]*model.SysMenu, error) {
	return s.Repo.SelectTreeAll(ctx)
}

func (s *SysMenuService) SelectTreeByUserId(ctx context.Context, userId int64) ([]*model.SysMenu, error) {
	return s.Repo.SelectTreeByUserId(ctx, userId)
}

func (s *SysMenuService) BuildMenus(menuList []*model.SysMenu) ([]*model.RouterVo, error) {
	return s.Repo.BuildMenus(menuList)
}

func (s *SysMenuService) BuildMenuTree(menuList []*model.SysMenu) ([]*model.SysMenu, error) {
	return s.Repo.BuildMenuTree(menuList)
}

func (s *SysMenuService) SelectListByMenuAndUserId(ctx context.Context, menu *model.SysMenu, userId int64) ([]*model.SysMenu, error) {
	return s.Repo.SelectListByMenuAndUserId(ctx, menu, userId)
}

func (s *SysMenuService) BuildMenuTreeSelect(menuList []*model.SysMenu) []*model.TreeSelect {
	return s.Repo.BuildMenuTreeSelect(menuList)
}

func (s *SysMenuService) BuildRoleMenuTreeSelect(ctx context.Context, userId, roleId int64) (*model.RoleMenuTreeSelect, error) {
	return s.Repo.BuildRoleMenuTreeSelect(ctx, userId, roleId)
}
